package com.zhibang.report.controller;

import com.sannuo.common.domain.Index;
import com.sannuo.common.result.Result;
import com.sannuo.common.result.ResultCode;
import com.zhibang.report.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/Index")
public class IndexController {
    @Autowired
    private IndexService indexService;

    @RequestMapping(value = "index1",method = RequestMethod.GET)
    public Result In(){
        List<Index> indices = indexService.selectIndex();
        System.out.println(indices);
        return Result.ok(ResultCode.SUCCESS,indices);
    }
    @RequestMapping(value = "oneMan",method = RequestMethod.GET)
    public Result In2(){
        Integer i = indexService.oneMan();
        Integer integer1 = indexService.oneWoMan();
        System.out.println(i);
        List<Integer> list=new ArrayList<>();
        list.add(i);
        list.add(integer1);
        Integer nan= list.get(0);
        Integer nv=list.get(1);
        Integer zrs=nan+nv;
        list.add(zrs);
        System.out.println("男生："+nan);
        System.out.println("女生："+nv);
        System.out.println("男生人数："+i);
        return Result.ok(ResultCode.SUCCESS,list);
    }

//    @RequestMapping(value = "nan",method = RequestMethod.GET)
//    public Result In3(){
//        Integer integer = indexService.oneMan();
//        List<Integer> list = new ArrayList<>();
//        list.add(integer);
//        return Result.ok(ResultCode.SUCCESS,list);
//    }
//    @RequestMapping(value = "nv",method = RequestMethod.GET)
//    public Result In4(){
//        Integer integer = indexService.oneWoMan();
//        List<Integer> list = new ArrayList<>();
//        list.add(integer);
//        return Result.ok(ResultCode.SUCCESS,list);
//    }
}
